<!DOCTYPE html>
<html>
<head>
    <title>random函数</title>
    <meta charset="utf-8"/>
    <script>
        function selectFrom(lowValue, upperValue){
            var choices = upperValue - lowValue + 1;
            return Math.floor(Math.random() * choices + lowValue);
        }

        for(var i = 0; i < 12; i++){
            var num = selectFrom(2, 10);
            alert(num);
        }

    </script>
</head>
<body>

</body>
</html>